#include "gtksymboliccolor.h"
#include "gtkstyleprovider.h"
#include "gtkstylecontextprivate.h"
+#include "gtkstylepropertiesprivate.h"
#include "gtkbindings.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
while (g_hash_table_iter_next (&iter, &key, &value))
{
- gchar *prop = key;
+ GParamSpec *pspec;
- /* Properties starting with '-' may be both widget style properties
- * or custom properties from the theming engine, so check whether
- * the type is registered or not.
- */
- if (prop[0] == '-' &&
- !gtk_style_properties_lookup_property (prop, NULL, NULL))
+ if (!gtk_style_properties_lookup_property (key, NULL, &pspec))
continue;
- gtk_style_properties_set_property (props,
- key,
- _gtk_css_selector_get_state_flags (info->selector),
- value);
+ _gtk_style_properties_set_property_by_pspec (props,
+ pspec,
+ _gtk_css_selector_get_state_flags (info->selector),
+ value);
}
}
return g_hash_table_lookup (priv->color_map, name);
}
-/**
- * gtk_style_properties_set_property:
- * @props: a #GtkStyleProperties
- * @property: styling property to set
- * @state: state to set the value for
- * @value: new value for the property
- *
- * Sets a styling property in @props.
- *
- * Since: 3.0
- **/
void
-gtk_style_properties_set_property (GtkStyleProperties *props,
- const gchar *property,
- GtkStateFlags state,
- const GValue *value)
+_gtk_style_properties_set_property_by_pspec (GtkStyleProperties *props,
+ GParamSpec *pspec,
+ GtkStateFlags state,
+ const GValue *value)
{
GtkStylePropertiesPrivate *priv;
- PropertyNode *node;
PropertyData *prop;
GType value_type;
GValue *val;
- g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
- g_return_if_fail (property != NULL);
- g_return_if_fail (value != NULL);
-
value_type = G_VALUE_TYPE (value);
- node = property_node_lookup (property);
- if (!node)
- {
- g_warning ("Style property \"%s\" is not registered", property);
- return;
- }
-
- if (node->pspec->value_type == GDK_TYPE_RGBA ||
- node->pspec->value_type == GDK_TYPE_COLOR)
+ if (pspec->value_type == GDK_TYPE_RGBA ||
+ pspec->value_type == GDK_TYPE_COLOR)
{
/* Allow GtkSymbolicColor as well */
g_return_if_fail (value_type == GDK_TYPE_RGBA ||
value_type == GDK_TYPE_COLOR ||
value_type == GTK_TYPE_SYMBOLIC_COLOR);
}
- else if (node->pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN)
+ else if (pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN)
{
/* Allow GtkGradient as a substitute */
g_return_if_fail (value_type == CAIRO_GOBJECT_TYPE_PATTERN ||
value_type == GTK_TYPE_GRADIENT);
}
else
- g_return_if_fail (node->pspec->value_type == value_type);
+ g_return_if_fail (pspec->value_type == value_type);
priv = props->priv;
- prop = g_hash_table_lookup (priv->properties, node->pspec);
+ prop = g_hash_table_lookup (priv->properties, pspec);
if (!prop)
{
prop = property_data_new ();
- g_hash_table_insert (priv->properties, node->pspec, prop);
+ g_hash_table_insert (priv->properties, pspec, prop);
}
val = property_data_get_value (prop, state);
g_value_copy (value, val);
}
+/**
+ * gtk_style_properties_set_property:
+ * @props: a #GtkStyleProperties
+ * @property: styling property to set
+ * @state: state to set the value for
+ * @value: new value for the property
+ *
+ * Sets a styling property in @props.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_style_properties_set_property (GtkStyleProperties *props,
+ const gchar *property,
+ GtkStateFlags state,
+ const GValue *value)
+{
+ PropertyNode *node;
+
+ g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
+ g_return_if_fail (property != NULL);
+ g_return_if_fail (value != NULL);
+
+ node = property_node_lookup (property);
+
+ if (!node)
+ {
+ g_warning ("Style property \"%s\" is not registered", property);
+ return;
+ }
+
+ _gtk_style_properties_set_property_by_pspec (props,
+ node->pspec,
+ state,
+ value);
+}
+
/**
* gtk_style_properties_set_valist:
* @props: a #GtkStyleProperties